/**
 * Created with IntelliJ IDEA.
 * Description:第 N个泰波那契数 -- 空间优化
 * User: YJ
 * Date: 2023-9-20
 * Time: 20:43
 */
public class TebonacciPro {

    public static int tebonacci(int n) {
        //空间优化
        int a = 0;
        int b = 1;
        int c = 1;
        int d = 0;
        for (int i = 3; i <= n; i++) {
            d = a + b + c ;
            a = b;
            b = c;
            c = d;
        }
        return d;
    }
    public static void main(String[] args) {
        System.out.println(tebonacci(25));
    }
}
